import Dexie from 'dexie';

const db = new Dexie('lali-pro');

db.version(10).stores({
    user: '++id, &name, password, role, showName',

    serialDevice: 'id',

    adjustData: '++id, adjustDistance, distanceRatio, adjustLali, distance, fiftyKg, hundredKg, minLali, totalDistance, zeroKg',

    measuredata:'++id, sample, username, createTime, createOn, customerName, sampleBatchNo, material',

    labProcess:'++id, name, prelali, preDownSpeed, preDownStopTime, preUpSpeed, preUpStopTime, lali, downSpeed, upSpeed',

    customerGoods: '++id, customerId, customerName, name, material',

    customers: '++id, name',

});

db.on("populate", function() {
    db.user.add({name: "admin", "password":"8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918","role":"ADMIN", "showName": "admin"});
    db.user.add({name: "superAdmin", "password":"08c1e89c0590b66c452d7370540b2dc6cf8be5c381a18f6ae5de234069ff79e2","role":"SUPERADMIN", "showName": "superadmin"});

    db.serialDevice.add({id: 1, name: "com1"});
    db.serialDevice.add({id: 2, name: "中国检测中心"});

    db.adjustData.add({id: 1,adjustDistance: 0, adjustLali: 0,distance: 23,distanceRatio: 1.5,fiftyKg: 10857,hundredKg: 25400,minLali: 0,totalDistance: 90,zeroKg: 2059});

    db.labProcess.add({id: 1,downSpeed: 300,lali: 50,name:"60",preDownSpeed: 300,preDownStopTime: 4,preUpSpeed: 150,preUpStopTime: 4,prelali: 100,stopTime: 20,upSpeed: 200});

    db.customerGoods.add({id:1, customerId:1, customerName:"测试客户", name: "样品", material: "塑料"});

    db.customers.add( {id:1, name: "测试客户"} )
});

export default db;
